package com.project.bohang.controller;


import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.project.bohang.common.model.Response;
import com.project.bohang.common.model.page.PageResult;
import com.project.bohang.entity.UserOutRiskRecord;
import com.project.bohang.entity.Visit;
import com.project.bohang.pojo.dto.UserOutRiskRecordDto;
import com.project.bohang.pojo.dto.VisitDto;
import com.project.bohang.pojo.vo.UserOutRiskRecordVo;
import com.project.bohang.pojo.vo.VisitVo;
import com.project.bohang.service.UserOutRiskRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;
import com.project.bohang.controller.BaseController;

/**
 *  用户外出记录 （用户）
 *
 * @author bohang
 * @since 2022-03-26
 */
@Controller
@RequestMapping("/userOutRiskRecord")
@ResponseBody
public class UserOutRiskRecordController extends BaseController {

    @Autowired
    private UserOutRiskRecordService userOutRiskRecordService;

    /**
     * 用户外出记录列表
     *
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public Response<PageResult<UserOutRiskRecordVo>> selectList(@RequestBody UserOutRiskRecordDto dto){
        return Response.success(getDataTable(userOutRiskRecordService.userSelectList(dto)));
    }

    /**
     * 新增用户外出记录
     *
     * @param req
     * @return
     */
    @PostMapping("/save")
    public Response save(@RequestBody UserOutRiskRecord req) {
        userOutRiskRecordService.save(req);
        return Response.success();
    }


    /**
     * 修改用户外出记录
     *
     * @param req
     * @return
     */
    @PostMapping("/update")
    public Response update(@RequestBody UserOutRiskRecord req) {
        UpdateWrapper<UserOutRiskRecord> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("id", req.getId());
        userOutRiskRecordService.update(req, updateWrapper);
        return Response.success();
    }

    /**
     * 删除用户外出记录
     *
     * @param req
     * @return
     */
    @PostMapping("/del")
    public Response del(@RequestBody UserOutRiskRecord req) {
        UserOutRiskRecord entity = new UserOutRiskRecord();
        entity.setId(req.getId());
        entity.setDeleted("1");
        userOutRiskRecordService.updateById(entity);
        return Response.success();
    }

    /**
     * 用户外出记录信息详情
     *
     * @param req
     * @return
     */
    @PostMapping("/detail")
    public Response<UserOutRiskRecord> detail(@RequestBody UserOutRiskRecord req) {
        UserOutRiskRecord userOutRiskRecord = userOutRiskRecordService.getById(req.getId());
        return Response.success(userOutRiskRecord);
    }
}

